package com.zm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class ApiController {

    @Autowired
    JdbcTemplate JdbcTemplate;

    @ResponseBody
    @RequestMapping("/hello")
    public  String  hello(){
        return "hello world";
    }

    @GetMapping("/result")
    public List<Map<String, Object>> userl(){
        String sql = "select * from my_user";
        List<Map<String, Object>> result = JdbcTemplate.queryForList(sql);

        return result;
    }

}
